package com.zdsoft.intercept;


import java.lang.reflect.Method;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
/**
 * 
 * <p>类描述:线程池中异常处理类</p>
 * @copyright www.zdsoft.cn
 * @author xingdaolin@msn.cn
 * @date  2016年12月1日
 * @version 1.0
 */
public class AsynThreadException implements AsyncUncaughtExceptionHandler {
	private static Logger log = LoggerFactory.getLogger(AsynThreadException.class); 
@Override
	public void handleUncaughtException(Throwable paramThrowable, Method paramMethod, Object... paramArrayOfObject) {
		// TODO Auto-generated method stub
		StringBuffer sb = new StringBuffer();
		sb.append("异常信息:").append(paramThrowable.getMessage()).append(",\t异常类").append(paramMethod.getClass().getName()).append(".").append(paramMethod.getName()).append("\t 执行参数：");
		Stream.of(paramArrayOfObject).forEach(x->{
			sb.append("类型:").append(x.getClass().getTypeName()).append(",参数值:").append(x.toString());
		});
		log.error(Thread.currentThread().getName()+"异常信息为:{}",sb.toString());
	}

}
